package com.example.service.Impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.mapper.TeamAndUserMapper;
import com.example.pojo.entity.TeamAndUser;
import com.example.service.TeamAndUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * TODO
 *
 * @author ding
 * @since 2024/6/17
 */
@Service
@DS("master")
public class TeamAndUserServiceImpl extends ServiceImpl<TeamAndUserMapper, TeamAndUser> implements TeamAndUserService {

    @Autowired
    private TeamAndUserMapper teamAndUserMapper;

    //根据团队id获取团队人数
    public int getCountByTeamId(Integer teamId){
        QueryWrapper<TeamAndUser> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("team_id",teamId);
        return Math.toIntExact(teamAndUserMapper.selectCount(queryWrapper));
    }


}
